﻿//-----------------------------------------------------------------------------------------------------------
//  Description:
//      职位相关
//      
//      
//  Comment                          Date                 Author      Email
//   ----------------------------    -------             -------      -----------------------------------
//  Create                           2012/12/29           wukun       17622690@qq.com
//
// 
//-----------------------------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Forest.Cat.Domain.Services;
using Forest.Cat.Domain.Services.Catalog;
using Forest.Core.Data;
using Forest.Cat.Domain.Entities;
using Forest.Cat.Domain.Services.WantAds;
using Forest.Cat.Domain.Shared;
using Forest.Cat.Domain.Configuration;
using Forest.Cat.Domain.Services.Compnaies;
using Forest.Cat.Domain;
using Forest.Cat.Domain.Services.Pictures;
using Forest.Cat.Domain.Services.Applications;
using Forest.Cat.Domain.Services.JobHunting;
using Forest.Core;
using System.Text;
using Forest.Cat.Admin.Controllers;

namespace Forest.Cat.Admin.Controllers
{
    public class CatalogController : BaseController
    {
        #region Const
        private const int _pageSize = 15;
        #endregion

        #region Fields
        private readonly IJobService _jobService;
        private readonly IJobPostingService _jobPostingService;
        private readonly IApplicationService _applicationService;
        private readonly ILovService _lovService;
        private readonly ICompanyService _companyService;
        private readonly INewsService _newsService;
        private readonly IWorkContext _workContext;
        private readonly IPictureService _pictureService;
        private readonly ISavedJobService _savedJobService;
        #endregion

        #region Constructures
        public CatalogController(IWorkContext workContext,
            IJobService jobService,
            IJobPostingService jobPostingService,
            IApplicationService applicationService,
            ILovService lovService,
            INewsService newsService,
            ICompanyService companyService,
            IPictureService pictureService,
            ISavedJobService savedJobService)
        {
            _workContext = workContext;
            _jobService = jobService;
            _jobPostingService = jobPostingService;
            _applicationService = applicationService;
            _lovService = lovService;
            _newsService = newsService;
            _companyService = companyService;
            _pictureService = pictureService;
            _savedJobService = savedJobService;
        }
        #endregion

        #region Methods

        //#region PrepareJobModel
        ///// <summary>
        ///// PrepareJobModel
        ///// </summary>
        ///// <param name="job"></param>
        ///// <param name="appliedJobIdList"></param>
        ///// <returns></returns>
        //[NonAction]
        //private JobModel PrepareJobModel(Job job, List<Guid> appliedJobIdList)
        //{
        //    var jobModel = job.ToModel();
        //    jobModel.JobDescription = jobModel.JobDescription;
        //    jobModel.YearsOfExperienceName = _lovService.GetLovName(job.YearsOfExperience.Value);
        //    jobModel.EducationLevelName = _lovService.GetLovName(job.EducationLevel.Value);
        //    jobModel.JobTypeName = _lovService.GetLovName(job.JobType);
        //    var company = _companyService.GetCompanyById(job.CompanyId.Value);
        //    var companyModel = company.ToModel();
        //    jobModel.CompanyModel = companyModel;
        //    var jobPostion = _jobPostingService.GetJobPostingById(job.Id);
        //    var jobPostionModel = jobPostion.ToModel();
        //    jobPostionModel.CityName = _lovService.GetLovName(jobPostion.City);
        //    jobPostionModel.DistrictName = jobPostion.District.HasValue ? _lovService.GetLovName(jobPostion.District.Value) : String.Empty;
        //    jobModel.JobPostingModel = jobPostionModel;
        //    if (appliedJobIdList != null)
        //    {
        //        jobModel.IsApplied = appliedJobIdList.Any(x => x.Equals(job.Id));
        //    }
        //    return jobModel;
        //}
        //#endregion

        //#region RecommendJobs
        //public ActionResult RecommendJobs()
        //{
        //    List<Job> jobList = new List<Job>();
        //    if (Request.IsAuthenticated)
        //    {
        //        jobList = _jobService.GetJobsRelatedByJobSeeker(_workContext.CurrentUser.Id).Take(10).ToList();
        //    }
        //    else
        //    {
        //        var viewdJobs = Request.Cookies["ViewdJobs"];
        //        if (viewdJobs != null)
        //        {
        //            Guid temp;
        //            var viewdJobList = viewdJobs.Value.Split(',').Where(x => !String.IsNullOrWhiteSpace(x) && Guid.TryParse(x, out temp)).
        //                Select(x => Guid.Parse(x));
        //            jobList = _jobService.GetJobsRelatedByViewdHistory(viewdJobList).Take(10).ToList();
        //        }
        //    }
        //    var model = jobList.Select(x => PrepareJobModel(x, null));
        //    return PartialView(model);
        //}
        //#endregion

        #endregion
    }
}
